home *** CD-ROM | disk | FTP | other *** search
- Path: ias_ppp0139.iamerica.net!72274.264
- From: 72274.264@compuserve.com (Sergey Kurtsev)
- Newsgroups: comp.lang.c++
- Subject: Re: Aborting Constructors
- Date: Wed, 31 Jan 1996 07:48:50 -0500
- Organization: Hello, all.
- Message-ID: <72274.264.57.001E55E1@compuserve.com>
- References: <4eoeck$t6n@news.ios.com>
- NNTP-Posting-Host: ias_ppp0139.iamerica.net
- X-Newsreader: Trumpet for Windows [Version 1.0 Rev B]
-
- In article <4eoeck$t6n@news.ios.com> leonardj@tribeca.ios.com (John Leonard) writes:
-
-
- <aborting constructors and stuff - skipped>
-
-
- NOTE: All further ideas are of my own...
- They were NOT tested !..
-
-
- If you want to call a destructor directly inside of the constructor - you
- can do this. But take into consideration next:
-
- 1. If you class is refrenced as an allocated on the heap
-
- //--------------
- class A {};
-
- main()
- {
- A *onHeap;
- onHeap=new A();
- };
- //--------------
-
- but not as a variable of a class type
- //--------------
- class A()
-
- main()
- {
- A classVar();
- };
- //--------------
-
- then you have to take care about deleting a class from the heap (in the
- constructor or outside of it, in the place it was called from). If you do
- delete it inside the constructor
-
- delete this;
-
- than logically class is not considered to be valid any more - it just doesn't
- exist. In the same time - if you don't use any vars after deleting - the code
- should still be valid, i.e. it shouldn't cause any lock ups or smth like this.
-
- 2. Destructor should never be called directly - but it doesn't cause any
- problems also if you use it's calls with a care.
-
- Good luck,
- Sergey.
-
-